Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming


Summary comparison of classes and procedures

Table 5–1 compares the application implemented by the sample classes (see the "Sample classes" section) with the equivalent application implemented by comparative procedures (see the "Comparative procedures" section). The code numbers in the table match the commented numbers in the code for both classes and procedures.

Table 5–1: Comparing sample classes to comparative procedures
Code No.
Sample classes
Comparative procedures
1
The acme.myObjs.CustObj class inherits from acme.myObjs.Common.CommonObj.
CustProc.p defines a handle variable and runs CommonProc.p persistently, setting the handle. CustProc.p then uses ADD-SUPER-PROCEDURE( ) to define CommonProc.p as a super procedure for it.
2
All the setup for acme.myObjs.CustObj takes place in the constructor.
All the setup for CustProc.p takes place in the main block of the procedure.
3
To establish an object reference to acme.myObjs.Common.ErrorObj, the method ErrorHandler( ) is invoked inside the acme.myObjs.CustObj class. It is found in the super class and returns an instance of acme.myObjs.Common.ErrorObj.
To establish a handle to ErrorProc.p, the ErrorHandler user-defined function, which returns a handle to ErrorProc.p is first defined as a prototype IN SUPER. The function is defined in the super procedure, CommonProc.p. It is later invoked CustProc.p and returns a handle to ErrorProc.p.
4
In ListDate( ) called on acme.myObjs.Common.HelperClass (through Main), when updateTimestamp( ) is invoked on acme.myObjs.CustObj, it is found in its super class, acme.myObjs.Common.CommonObj.
In Main.p, when updateTimestamp is called in CustProc.p, it is found in its super procedure, CommonProc.p.
5
The updateTimestamp( ) method initializes the value of the timestamp data member in acme.myObjs.Common.CommonObj. Because it is an inherited data member, it can be referenced in acme.myObjs.CustObj.
The updateTimestamp procedure in CommonProc.p initializes the value of the SHARED variable, timestamp. In order for CustProc.p to use timestamp, it must define it as NEW SHARED.
6
When acme.myObjs.CustObj is deleted, the destructor automatically runs and cleans up program resources.
Before deleting the procedure object, the internal procedure CleanUp is called in Main.p to clean up resources.
7
The acme.myObjs.NECustomer class inherits from acme.myObjs.CustObj.
NECustomer.p must go through the same process to add CustProc.p as a super procedure, as did CustProc.p to add CommonProc.p as a super procedure, described earlier.
8
The constructor for acme.myObjs.NECustomer invokes the constructor for acme.myObjs.CustObj. If it had parameters to pass (which it does not in this case), it would do that here.
If CustProc.p took parameters (which it does not in this case) then NECustomer.p would have to pass them when CustProc.p is run.
9
acme.myObjs.NECustomer overrides the GetCustomerName( ) method in acme.myObjs.CustObj. The override uses the SUPER system reference to invoke the super class implementation of this method.
NECustomer.p defines a separate version of the GetCustomerName internal procedure defined in the super procedure CustProc.p. The NECustomer.p version uses the RUN SUPER statement to invoke the super procedure implementation of this internal procedure.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095